package client;

import msg.MsgHistoryBack;
import msg.MsgHistory;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Calendar;

/**
 *
 * @author tomek
 */
public class HistoryRequest {

    private Calendar cal;
    private long longFrom;
    private long longTo;
    private static gui.HistoryRequestGui myGui;
    
    public HistoryRequest() {
        myGui = new gui.HistoryRequestGui(this);
        cal = Calendar.getInstance();
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                myGui.showGui();
            }
        });
    }
    
    public static void main(String args[]) {
        
        
    }   
    
    public MsgHistoryBack sendHistoryRequest(int[] from, int[] to) {
        cal.set(from[0], from[1], from[2], from[3], from[4]);
        longFrom = cal.getTimeInMillis();
        
        cal.set(to[0], to[1], to[2], to[3], to[4]);
        longTo = cal.getTimeInMillis();
        
        System.out.println("od: "+longFrom+", do: "+longTo);

        MsgHistory ms = new MsgHistory(Client.getLogin(), longFrom, longTo);
        Connection c =  new Connection(1026);
        MsgHistoryBack historyBack = c.history(ms);

        return historyBack;
    }
   
}
